﻿// cmdAddConeSurfaceCommand.cpp
//

#include "stdafx.h"


////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//
// BEGIN AddConeSurfaceCommand command
//

#pragma region AddConeSurfaceCommand command

class CCommandAddConeSurfaceCommand : public CRhinoCommand
{
public:
	CCommandAddConeSurfaceCommand() = default;
	UUID CommandUUID() override
	{
		// {1cf5ab12-1833-4cba-843d-a8cf7493e90c}
		static const GUID AddConeSurfaceCommandCommand_UUID =
		{0x1cf5ab12,0x1833,0x4cba,{0x84,0x3d,0xa8,0xcf,0x74,0x93,0xe9,0x0c}};
		return AddConeSurfaceCommandCommand_UUID;
	}
	const wchar_t* EnglishCommandName() override { return L"AddConeSurface"; }
	CRhinoCommand::result RunCommand(const CRhinoCommandContext& context) override;
};

// The one and only CCommandAddConeSurfaceCommand object
static class CCommandAddConeSurfaceCommand theAddConeSurfaceCommandCommand;

CRhinoCommand::result CCommandAddConeSurfaceCommand::RunCommand(const CRhinoCommandContext& context)
{
	ON_Plane plane = ON_xy_plane;
	double height = 10.0;
	double radius = 5.0;
	BOOL bCapBottom = FALSE;

	ON_Cone cone(plane, height, radius);
	if (cone.IsValid())
	{
		ON_Brep* cone_brep = ON_BrepCone(cone, bCapBottom);
		if (cone_brep)
		{
			CRhinoBrepObject* cone_object = new CRhinoBrepObject();
			cone_object->SetBrep(cone_brep);
			context.m_doc.AddObject(cone_object);
			context.m_doc.Redraw();
		}
	}

	return CRhinoCommand::success;
}

#pragma endregion

//
// END AddConeSurfaceCommand command
//
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
